/*
 * @Author: 无聊 7989314+Hwz1997@user.noreply.gitee.com
 * @Date: 2025-07-01 14:13:48
 * @LastEditors: 无聊 7989314+Hwz1997@user.noreply.gitee.com
 * @LastEditTime: 2025-09-03 02:50:31
 * @FilePath: \keep_motion_api\models\data\sportCalendar.model.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

// 运动日历模型
const sportCalendarSchema = new Schema({
  user_id: { 
    type: Schema.Types.ObjectId, 
    ref: 'User',
    required: true 
  },
  date: { type: Date, required: true },
  completed_plans: [{
    type: Schema.Types.ObjectId, 
    ref: 'TrainingPlan'
  }],
  activity_records: [{
    type: Schema.Types.ObjectId, 
    ref: 'SportRecord'
  }],
  notes: String,
  activities: [{
    activity_id: { type: Schema.Types.ObjectId, ref: 'Activity' },
    status: {
      type: String,
      enum: ["planned", "in_progress", "completed", "skipped"]
    }
  }],
  course_sessions: [{
    course_id: { type: Schema.Types.ObjectId, ref: 'Course' },
    lesson_id: Schema.Types.ObjectId,
    duration: Number
  }]
});
sportCalendarSchema.statics.getCalendars = async function (user_id) {
  return await this.find({ user_id });
}
sportCalendarSchema.statics.exportCalendar = async function (user_id) {
  return await this.find({ user_id });
}
sportCalendarSchema.statics.getInsights = async function (user_id) {
  return await this.find({ user_id });
}

module.exports = mongoose.model('SportCalendar', sportCalendarSchema);
